/*
 * @Author: kls
 * @Date: 2023-08-04 09:12:06
 * @LastEditTime: 2023-08-08 15:37:18
 * @LastEditors: kls
 * @Description:
 * @FilePath: \jnks-drone-company\src\main.js
 */
import './styles/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import ElTableInfiniteScroll from 'el-table-infinite-scroll'
import router from './router'
import { message } from './utils/reWriteMessage.js'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import '@/utils/drag'
import directives from '@/utils/directive.js'
const app = createApp(App)
//注册elementplus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(ElTableInfiniteScroll)
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(createPinia())
app.use(router)
app.use(directives)
app.provide('$message', message)

// 方法：注册播放音频事件到Vue实例上
app.provide('playAudio', function (fileName) {
  try {
    let buttonAudio = document.getElementById('eventAudio')
    buttonAudio.setAttribute('src', '/audio/droneAlert.mp3')
    buttonAudio.play()
  } catch (error) {}
})
app.mount('#app')
